package com.woniuxy.table.app.apiImpl;



import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.table.client.TableMannageClient;
import com.woniuxy.table.client.param.AddTableParam;
import com.woniuxy.table.client.param.ModifyTableParam;
import com.woniuxy.table.service.DinnerTableService;
import com.woniuxy.table.service.param.ModifyTableServiceParam;
import com.woniuxy.table.service.param.AddTableServiceParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
import result.Result;


@RestController
public class TableMannageApiImpl implements TableMannageClient {
    @Autowired
    private DinnerTableService dinnerTableService;

    @Log("添加餐桌")
    @Override
    public Result addTable(AddTableParam addTableParam) {
        AddTableServiceParam addTableServiceParam = BeanUtil.toBean(addTableParam, AddTableServiceParam.class);
        dinnerTableService.addTable(addTableServiceParam);
        return Result.success("添加餐桌成功");
    }
    @Log("修改餐桌信息")
    @Override
    public Result modifyTable(ModifyTableParam modifyTableParam) throws Exception {
        ModifyTableServiceParam modifyTableServiceParam = BeanUtil.toBean(modifyTableParam, ModifyTableServiceParam.class);
        dinnerTableService.modifyTable(modifyTableServiceParam);
        return Result.success("修改餐桌信息成功");
    }
    @Log("删除餐桌")
    @Override
    public Result deleteTable(Integer storeId, Integer tableId) {
        dinnerTableService.deleteTable(storeId,tableId);
        return Result.success("删除餐桌成功");
    }


}
